<template>
  <base-breadcrumb>
    <template>
      <a-card class="mb20">
        <titleName title="基础信息填写" class="title-style"></titleName>
        <a-form-model ref="ruleForm" :model="form" :rules="rules" :hideRequiredMark="true">
          <a-row :gutter="24">
            <a-col :md="8" :sm="8">
              <a-form-model-item
                label="所属分公司："
                prop="branchComId"
                :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
              >
                <BaseInput placeholder="请选择" v-model="form.branchComId"></BaseInput>
              </a-form-model-item>
            </a-col>

            <a-col :md="8" :sm="8">
              <a-form-model-item
                label="所属项目："
                prop="projectId"
                :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
              >
                <BaseInput
                  placeholder="请选择"
                  v-model="form.projectId"

                ></BaseInput>
              </a-form-model-item>
            </a-col>
            <a-col :md="8" :sm="8">
              <a-form-model-item
                label="分包商名称："
                prop="subContractorId"
                :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
              >
                <BaseInput placeholder="请选择" v-model="form.subContractorId">

                </BaseInput>
              </a-form-model-item>
            </a-col>
            <a-col :md="8" :sm="8">
              <a-form-model-item
                label="名称："
                prop="name"
                :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
              >
                <BaseInput placeholder="请输入" v-model="form.name" />
              </a-form-model-item>
            </a-col>
            <a-col :md="8" :sm="8">
              <a-form-model-item
                label="编号"
                prop="number"
                :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
              >
                <BaseInput placeholder="请输入" v-model="form.number" />
              </a-form-model-item>
            </a-col>
            <a-col :md="8" :sm="8">
              <a-form-model-item
                label="计量月份："
                prop="measureMonth"
                :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                :wrapperCol="{ lg: { span: 16 }, sm: { span: 17 } }"
              >
                <a-month-picker placeholder="请选择" v-model="form.measureMonth"></a-month-picker>
              </a-form-model-item>
            </a-col>
            <a-col :md="8" :sm="8">
              <a-form-model-item
                label="施工范围："
                prop="constructionRange"
                :labelCol="{ lg: { span: 6 }, sm: { span: 6 } }"
                :wrapperCol="{ lg: { span: 16 }, sm: { span: 16 } }"
              >
                <BaseTextarea placeholder="请输入" v-model="form.constructionRange"  />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </a-card>
      <a-row :gutter="24">
        <a-col :offset="18" class="foot-btn page-btn-right-top">
          <!-- <a-button type="danger" @click="deleteDraft()">删除草稿</a-button> -->
          <a-button type="primary" @click="submitForm('0')">保存草稿</a-button>
          <a-button type="primary" @click="submitForm('1')">提交</a-button>
          <a-button type="primary" @click="closeForm()">关闭</a-button>
        </a-col>
      </a-row>
    </template>
  </base-breadcrumb>
</template>
<script>
import { addStepOne ,getStepOneDetail} from '@/api/businessAffairs/sml'
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司
import SelectProject from '@/components/Select/SelectProject' // 分公司
export default {
    name:'a'+Date.now(),
    components: {
        SelectSubCompany,
        SelectProject,
    },
    data() {
        return {
            form: {},
            id: '',

        }
    },
    mounted() {
        if (this.$route.query.id) {
            this.id = this.$route.query.id
            console.log(this.id)
            this.getStepOne()
        }
    },
    methods: {
        getStepOne() {
            let params = {
                id: this.id,
            }
            getStepOneDetail(params).then(res=>{
              this.form = res.data;
            })
        },
        handleChange(e) {
            console.log(e)
        },
        // 提交表单
        submitForm(auditStatus) {
            this.form.auditStatus = auditStatus
            this.$refs.ruleForm.validate((valid) => {
                if (valid) {
                    addStepOne(this.form).then((res) => {
                        console.log(res)
                        this.$message.success('操作成功')
                        this.$router.push('/businessAffairs/subcontractMeasurement/sml')

                    })
                } else {
                  this.$message.warning("请填写完所有必填项信息")
                }
            })
        },
        // 关闭表单
        closeForm() {
            this.$router.go(-1)
        },
    },
}
</script>
<style lang="less">
.step-text {
    .ant-steps-item-title {
        width: 168px;
    }
}
.check-box {
    .ant-checkbox-group {
        margin-top: 1.5%;
        display: flex;
        justify-content: space-between;
    }
    .ant-checkbox-group-item {
        position: static !important;
    }
}
.radio-box {
    .ant-radio-wrapper {
        position: static !important;
    }
    .ant-radio-group {
        margin-top: 3% !important;
        display: flex;
    }
}

.foot-btn {
    display: flex;
    justify-content: space-between;
}
</style>
